<template>
  <div id="app">
    <router-view />
    <!-- $route 当前路由对象 -->
    <!-- 适合单一页面,不适合多个页面 -->
    <!-- <van-tabbar v-if="$route.name == 'city' ? false : true" route> -->
    <!-- 适用于多个页面 -->
    <van-tabbar v-if="$route.meta.isShow" route>
      <van-tabbar-item replace to="/home" icon="home-o"> 
        首页 
      </van-tabbar-item>
      <van-tabbar-item replace to="/topic" icon="description">
        专题
      </van-tabbar-item>
      <van-tabbar-item replace to="/category" icon="home-o">
        分类
      </van-tabbar-item>
      <van-tabbar-item replace to="/cart" icon="cart-o">
        购物车
      </van-tabbar-item>
      <van-tabbar-item replace to="/my" icon="user-o">
        我的
      </van-tabbar-item>
    </van-tabbar>
  </div>
</template>

<script>
export default {
  watch: {
    "$route":function(){ //监听路由切换
      console.log(this.$route.meta.isShow);
    }
  },
  created(){
    var userInfo = {

      "openId":"13383916639",

      "nickName":"赵六",

      "avatarUrl":"https://wx.qlogo.cn/mmopen/vi_32/Q0j4TwGTfTIbWFEIJj8IpGeHM7dGic1aTFZALjWcMm9ltWfFiaQfVRYticWBfgGfzXWMt2EkJWiaicPtftHAlWxUibxQ/132"

    };

    var openId = userInfo.openId;

    localStorage.setItem("userInfo", JSON.stringify(userInfo));

    localStorage.setItem("openId", openId);
  }
}
</script>

<style scoped lang="scss">
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
}

#nav {
  padding: 30px;

  a {
    font-weight: bold;
    color: #2c3e50;

    &.router-link-exact-active {
      color: #42b983;
    }
  }
}
</style>
